package org.mtdownload.chartview;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TaskSeries {

	private List<long[]> speeds=new ArrayList<long[]>();
	private long maxSpeed=-1;
	private long[] maxThreadsSpeed=null;
	
	public TaskSeries() {	
		/*empty constructor*/
	}
	
	public void addSpeeds(long[] s){
		if(s==null||s.length<=0){
			return;
		}
		if(!speeds.contains(s)){
			speeds.add(s);
		}
		if(maxThreadsSpeed==null){
			maxThreadsSpeed=new long[s.length];
			Arrays.fill(maxThreadsSpeed,-1);
		}
		for(int i=0;i<s.length;i++){
			if(s[i]>maxSpeed){
				maxSpeed=s[i];
			}
			if(s[i]>maxThreadsSpeed[i]){
				maxThreadsSpeed[i]=s[i];
			}
		}
	}
	
	public List<long[]> getSpeedsList(){
		return speeds;
	}

	/**
	 * @return Returns the maxSpeed.
	 */
	public long getMaxSpeed() {
		return maxSpeed;
	}
	
	public long getMaxThreadSpeed(int index){
		return maxThreadsSpeed[index];
	}
	
	public int getThreadsNumber(){
		if(maxThreadsSpeed==null){
			return 1;
		}else{
			return maxThreadsSpeed.length;
		}
	}
}
